The CW_FIELD function creates a widget data entry field. The field consists of a label and a text widget. CW_FIELD can create string, integer, or floating-point fields. The default is an editable string field.
This routine is written in the IDL language. Its source code can be found in the file cw_field.pro in the lib subdirectory of the IDL distribution.
Result = CW_FIELD( Parent [, /ALL_EVENTS] [, /COLUMN] [, FIELDFONT=font] [, /FLOATING | , /INTEGER | , /LONG | , /STRING] [, FONT=string] [, FRAME=pixels] [, /NOEDIT] [, /RETURN_EVENTS] [, /ROW] [, TAB_MODE=value] [, TEXT_FRAME=pixels] [, TITLE=string] [, UNAME =string] [, UVALUE=value] [, VALUE=value] [, XSIZE=characters] [, YSIZE=lines] )
This function returns the widget ID of the newly created field widget.
The widget ID of the parent widget.
Like RETURN_EVENTS, but return an event whenever the contents of a text field have changed.
Set this keyword to center the label above the text field. The default is to position the label to the left of the text field.
Set this keyword to a string containing the name of the font to use for the TEXT part of the field.
Set this keyword to have the field accept only floating-point values. Any number or string entered is converted to its floating-point equivalent.
Note: Floating-point fields are not editable.
Set this keyword to a string containing the name of the font to use for the TITLE of the field. The font specified is a “device font” (an X Windows font on Motif systems; a TrueType or PostScript font on Windows systems). See Using Device Fonts for details on specifying names for device fonts. If this keyword is omitted, the default font is used.
Set this keyword to the width, in pixels, of a frame to be drawn around the entire field cluster. The default is no frame.
Set this keyword to have the field accept only integer values. Any number or string entered is converted to its integer equivalent (using FIX). For example, if 12.5 is entered in this type of field, it is converted to 12.
Note: Integer fields are not editable.
Set this keyword to have the field accept only long integer values. Any number or string entered is converted to its long integer equivalent (using LONG).
Note: Long integer fields are not editable.
Normally, the value in the text field can be edited. Set this keyword to make the field non-editable.
Set this keyword to make CW_FIELD return an event when a carriage return is pressed in a text field. The default is not to return events. Note that the value of the text field is always returned when the following command is used:
WIDGET_CONTROL, field, GET_VALUE = X
Set this keyword to position the label to the left of the text field. This is the default.
Set this keyword to have the field accept only string values. Numbers entered in the field are converted to their string equivalents. This is the default.
Set this keyword to one of the values shown in the table below to determine how the widget hierarchy can be navigated using the Tab key. The TAB_MODE setting is inherited by lower-level bases and child widgets unless it is explicitly set on an individual widget.
Note: It is not possible to tab to disabled (SENSITIVE=0) or hidden (MAP=0) widgets.
Valid settings are:
Value |
Description |
0 |
Disable navigation onto or off of the widget. This is the default. Child widgets automatically inherit the tab mode of the parent base as described in Inheriting the TAB_MODE Value. |
1 |
Enable navigation onto and off of the widget. |
2 |
Navigate only onto the widget. |
3 |
Navigate only off of the widget. |
Note: In widget applications on the UNIX platform, the Motif library controls what widgets are brought into and released from focus using tabbing. The TAB_MODE keyword value is always zero, and any attempt to change it is ignored when running a widget application on the UNIX platform. Tabbing behavior may vary significantly between UNIX platforms; do not rely on a particular behavior being duplicated on all UNIX systems.
Set this keyword to the width in pixels of a frame to be drawn around the text field. Note that this keyword is only a “hint” to the toolkit, and may be ignored in some instances. Under Microsoft Windows, text widgets always have a frame of width 1 pixel.
A string containing the text to be used as the label for the field. The default is “Input Field”.
Note: You can use language catalogs to internationalize this value with strings in particular languages.
Set this keyword to a string that can be used to identify the widget in your code. You can associate a name with each widget in a specific hierarchy, and then use that name to query the widget hierarchy and get the correct widget ID.
To query the widget hierarchy, use the WIDGET_INFO function with the FIND_BY_UNAME keyword. The UNAME should be unique to the widget hierarchy because the FIND_BY_UNAME keyword returns the ID of the first widget with the specified name.
The “user value” to be assigned to the widget.
The initial value in the text widget. This value is automatically converted to the type defined by the STRING, INTEGER, LONG, and FLOATING keywords.
An explicit horizontal size (in characters) for the text input area. The default is to let the window manager size the widget. Using the XSIZE keyword is not recommended.
An explicit vertical size (in lines) for the text input area. The default is 1.
The widget ID returned by most compound widgets is actually the ID of the compound widget’s base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets.
In addition, you can use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL to obtain or set the value of the field. If one of the FLOATING, INTEGER, LONG, or STRING keywords to CW_FIELD is set, values set with the SET_VALUE keyword to WIDGET_CONTROL will be forced to the appropriate type. Values returned by the GET_VALUE keyword to WIDGET_CONTROL will be of the type specified when the field widget is created. Note that if the field contains string information, returned values will be contained in a string array even if the field contains only a single string.
See Writing Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO.
This widget generates event structures with the following definition:
event = { ID:0L, TOP:0L, HANDLER: 0L, VALUE:'', TYPE:0 , UPDATE:0}
The VALUE field is the value of the field. TYPE specifies the type of data contained in the field and can be any of the following: 0=string, 1=floating-point, 2=integer, 3=long integer (the value of TYPE is determined by setting one of the STRING, FLOAT, INTEGER, or LONG keywords). UPDATE contains a zero if the field has not been altered or a one if it has.
The code below creates a main base with a field cluster attached to it. The cluster accepts string input, has the title “Name”, and has a frame around it:
base = WIDGET_BASE()
field = CW_FIELD(base, TITLE = "Name", /FRAME)
WIDGET_CONTROL, base, /REALIZE
Pre 4.0 |
Introduced |
6.1 |
Added TAB_MODE keyword |